<?php
include_once 'fun.php';
include_once 'islogin.php';
var_dump($_POST);
    $oldpassword=isset($_POST['oldpasswd'])?md5($_POST['oldpasswd']):'';
    $newPassword = isset($_POST['newpassword'])?md5($_POST['newpassword']):'';   
    $Password = isset($_POST['password'])?md5($_POST['password']):'';
    $id=$_POST['id'];
    $pwd=$_POST['PWD'];
    var_dump($oldpassword);
    if($oldpassword!=$pwd)
    {
        echo "<script>alert('密码不正确'); history.back();</script>";
        exit;
    }
    if($Password==''&&$newPassword=='')
    {
        echo "<script>alert('请输入新密码'); history.back();</script>";
        exit;
    }
    if($Password!=$newPassword)
    {
        echo "<script>alert('两次密码不正确'); history.back();</script>";
        exit;
    }


    $sql = "update user set password='{$Password}' where id = '{$id}'";
    $con=connect();
    query($sql,$con);
    echo "<script>alert('保存成功'); history.back();</script>";
    
?>